<template>
	 <el-input v-model="value">
		<template #append>
			<el-button @click="toOpen">选择</el-button>
		</template>
	 </el-input>
 	 <mdp-dialog ref="dialog"> 
			<template #default="{visible}">
				<mdp-select-table v-if="visible" v-model="value" title="选择主键" :loadFun="getTableColumnList"/>
			</template>
		
	 </mdp-dialog>
</template> 
<script> 
import {getTableColumnList} from '@/api/mdp/dm/meta'
export default {
	name: 'MdpInputSelectTableField',
	inject: ['designer'],
	props: {
		modelValue: {
			type:[String,Array,Object],
			default:function(){
				return null
			}
		}
	},
	computed: {
		value:{
			set(val){
				this.$emit('update:modelValue',val)
			},
			get(){
				return this.modelValue
			}
		}
	}, 
	methods:{
		getTableColumnList,
		toOpen(){ 
			var children=this.designer.ctx.dragForm.rule[0].children; 
			var plusOptions=[];
			children.forEach(k=>{
				var field=k.children[0]
				plusOptions.push({id:field.field,name:field.title})
			})
			
			this.$refs['dialog'].open({plusOptions:plusOptions})
		}
	},
	mounted() { 
	}
}
</script>
